package handwriting.learning;

import handwriting.editor.SampleData;
import handwriting.learning.Identifier;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class RandomTester {
	public static void main(String[] args) throws FileNotFoundException {
		if (args.length != 3) {
			System.out.println("java RandomTester numNetworks numHidden testingSet");
			System.exit(1);
		}
		
		int numNetworks = Integer.parseInt(args[0]);
		int numHidden = Integer.parseInt(args[1]);
		File testFile = new File(args[2]);
		SampleData testSet = SampleData.parseDataFrom(new Scanner(testFile));
		
		ArrayList<Integer> testsPassed = new ArrayList<Integer>();
		for (int test = 0; test < numNetworks; ++test) {
            //Identifier ai = Identifier(testSet, numHidden); /* put your constructor here in place of null!!!*/
			RecognizerAI ai = null;
			//TODO fix this ^
			int numCorrectTests = ai.numCorrectTests(testSet);
			testsPassed.add(numCorrectTests);
			System.out.println("number of tests passed: " + numCorrectTests + "/" + testSet.numDrawings());
		}
		
		double meanPassed = RecognizerAI.mean(testsPassed);
		double stdDevPassed = RecognizerAI.stdDev(testsPassed);

		System.out.println("Summary:");
		System.out.println("Hidden nodes: " + numHidden);
		System.out.println("Test file: " + testFile.getName());
		System.out.println("Number of networks: " + numNetworks);
		System.out.println("Mean tests passed: " + meanPassed + " +/-" + stdDevPassed);
	}
}
